package ui
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.utils.Timer;
	
	public class Welcome extends Sprite
	{
		public function Welcome()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE,onAdded);
			timer=new Timer(25,2)
			timer.addEventListener(TimerEvent.TIMER,onTimer);
			timer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
		}
		
		public function get onComplete():Function
		{
			return _onComplete;
		}

		public function set onComplete(value:Function):void
		{
			_onComplete = value;
		}

		private function onAdded(e:Event):void
		{
			txtf.defaultTextFormat=new  TextFormat("",16,0xffff00,"bold");
			txtf.text=CLocale.getValue("welcome1");
			txtf.autoSize=flash.text.TextFieldAutoSize.LEFT;
			txtf.x=(stage.stageWidth-txtf.textWidth)*.5;
			txtf.y=(stage.stageHeight-txtf.textHeight)*.5;
			this.addChild(txtf);
			
			timer.delay=1000;
			timer.start();
		}
		
		private function onTimer(e:TimerEvent):void
		{
			txtf.text=CLocale.getValue("welcome2");
		}
		
		private function onTimerComplete(e:TimerEvent):void
		{
			timer=null;
			if(_onComplete!=null)
				_onComplete();
		}
		
		//
		private var timer:Timer;
		private var txtf:TextField	=new TextField();
;
		private var _onComplete:Function;
	}
}